import sys

# add parent dir to python system path
sys.path.append('')

from SymGroup import *

class IdentityBasedEncryption(SymGroup):
    def __init__(self):
        super(IdentityBasedEncryption, self).__init__()

    def system_build(self):
        """ return system parameters """
        pass

    def key_extract(self, user_id, sys_params):
        """ generate a user key pair dictionary that contains 'usk' and 'upk' according to the given user id and
        system main secret key """
        pass

    def encryption(self, m, sys_params, user_params):
        """ encrypt message m with params """
        pass

    def decryption(self, ciphertext, user_params):
        """ decrypt ciphertext with params """
        pass

    def test(self, m, user_id):
        print('message: ', m)
        print('user id: ', user_id)
        system_params = self.system_build()
        print('system params: ', system_params)
        user_params = self.key_extract(user_id, system_params)
        print('user params:', user_params)
        ciphertext = self.encryption(m, system_params, user_params)
        print('ciphertext: ', ciphertext)
        dec_m = self.decryption(ciphertext, user_params)
        print('decrypt message: ', dec_m)
        assert m == dec_m, 'decryption failed'
        print('decryption success')
